﻿<%@ Page Title="" Language="C#" MasterPageFile="~/web/common/admin_common.Master" AutoEventWireup="true" CodeBehind="List.aspx.cs" Inherits="shop.web.view_admin.goods.List" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>商品列表</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <form class="layui-form">
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">商品类别</label>
            <div class="layui-inline">

                <select lay-verify="required" name="catagoryId">
                    <option></option>
                    <%foreach (var catagory in catagoryList)
                        {
                    %>

                    <option value="<%=catagory.Id %>"><%=catagory.Name %></option>
                    <%
                        }
                    %>
                </select>

            </div>
            <div class="layui-inline">
                 <input type="submit" value="查找" class="layui-btn" />
            </div>
           
            <div class="layui-inline">
                <a class="layui-btn" href="Add.aspx">添加</a>
            </div>
        </div>

    </form>
    <div>
        <%--<img src="/web/resource/img<%=go %>" alt="Alternate Text" />--%>
    </div>
    <asp:Repeater ID="goodsListId" runat="server">
        <HeaderTemplate>
            <table class="layui-table" lay-skin="row line">
                <tr class="tr1">
                    <td>编号</td>
                    <td>名称</td>
                    <td>描述</td>
                    <td>价格</td>
                    <td>图片路径</td>
                    <td>商品类别</td>
                    <td colspan="3">操作</td>
                </tr>
        </HeaderTemplate>
        <ItemTemplate>
            <tr class="tr2">
                <td><%#Eval("Id") %></td>
                <td><%#Eval("Name") %></td>
                <td><%#Eval("Description") %></td>
                <td><%#Eval("Price") %></td>
                <td><%#Eval("Image.imagePath") %></td>
                <td><%#Eval("Catagory.Name") %></td>
                <td><a href="/web/view_admin/goods/Detail.aspx?id=<%#Eval("Id") %>" class="layui-btn  layui-btn-xs">查看</a></td>
                <td><a href="/web/view_admin/goods/edit.aspx?id=<%#Eval("Id") %>" class="layui-btn  layui-btn-xs">编辑</a></td>
                <td><a href="javascript:deleteGoods( <%#Eval("Id") %> )" class="layui-btn layui-btn-danger layui-btn-xs">删除</a></td>
            </tr>
        </ItemTemplate>
        <FooterTemplate>
            </table>
        </FooterTemplate>
    </asp:Repeater>
    <script>
        function deleteGoods(id) {
            var index = layer.confirm('确定删除该商品？', { icon: 3, title: '提示' }, function (index) {
                $.post("/handler/GoodsHandler.ashx?method=delete&id=" + id, function (data) {
                    var obj = JSON.parse(data);
                    console.log(data)
                    if (obj.ErrorCode === 0) {
                        //成功
                        layer.msg(obj.Message, { icon: 6 }, function () {
                            window.location.reload();
                        });


                    } else {
                        layer.msg(obj.Message, { icon: 2 })
                    }
                })

                layer.close(index);
            });

        }
    </script>
</asp:Content>
